<template>
	<view>
		<view>
			<view class="tglist" @click="toTgcompy()">
				<text style="margin-left: 30rpx;color: white;font-size: 35rpx;">我的推广企业</text>
				<view class="tglist-right">
					<view style="margin-right: 30rpx;"><text style="font-size: 50rpx;">{{entPassTotal}}</text>家</view>
					<u-icon name="arrow-right" color="#ffffff" size="40rpx"></u-icon>
				</view>
			</view>
			<u-divider v-if="tgcompylist.length>0" text="间接推广企业" textPosition="left"></u-divider>
			<view class="tglist" v-for="item in tgcompylist" @click="toTgcompy(item.id)" style="background-color: gray;">
				<text style="margin-left: 30rpx;color: white;font-size: 35rpx;">{{item.userName}}</text>
				<view class="tglist-right">
					<view style="margin-right: 30rpx;"><text style="font-size: 50rpx;">{{item.subEnterpriseCount}}</text>家</view>
					<u-icon name="arrow-right" color="#ffffff" size="40rpx"></u-icon>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import Index from "@/common/index-model.js"
	import fun from '@/common/publicFun.js'
	let index = new Index()
	let that = null
	export default {
		data() {
			return {
				tgcompylist:[],
				entPassTotal:0
			}
		},
		onLoad() {
			this.getTgcompylist()
			this.getpasstotal()
		},
		methods: {
			toTgcompy(data){
				if(data == undefined){
					data = uni.getStorageSync('userid')
				}
				
				index.navigate_to('../tgcompy/index?id='+data)
			},
			getTgcompylist(){
				console.log(uni.getStorageSync('userid'))
				index.getPublicUserMember({},'client/enterprise/info/countByTopAgent/'+uni.getStorageSync('userid'),'get',res=>{
					if(res.data.code == 200 && res.data.success){
						this.tgcompylist = res.data.result
					}else{
						console.log("请求失败")
					}
				})
			},
			getpasstotal(){
				index.getPublicUserMember({
					pId:uni.getStorageSync('userid')
				},'client/enterprise/info/enterCountByInvitePId','get',res=>{
					if(res.data.code == 200 && res.data.success){
						this.entPassTotal = res.data.result.succCount
					}else{
						console.log("请求失败") 
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
.tglist{
	margin: 40rpx auto;
	width: 90%;
	height: 150rpx;
	border-radius: 30rpx;
	background-color: royalblue;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: space-between;
	.tglist-right{
			color: white;
			margin-right: 20rpx;
			display: flex;
		}
}

</style>
